import { IPSDEAction } from '../action/ipsdeaction';
import { IPSDEDataSet } from '../ds/ipsdedata-set';
import { IPSDEServiceAPI } from './ipsdeservice-api';
import { IPSDEServiceAPIMethod } from './ipsdeservice-apimethod';
import { IPSDEServiceAPIMethodInput } from './ipsdeservice-apimethod-input';
import { IPSDEServiceAPIMethodReturn } from './ipsdeservice-apimethod-return';
import { IPSSysSFPlugin } from '../../res/ipssys-sfplugin';
import { IPSSubSysServiceAPIDEMethod } from '../../service/ipssub-sys-service-apidemethod';
import { PSModelObjectImpl } from '../../psmodel-object-impl';

export class PSDEServiceAPIMethodImpl extends PSModelObjectImpl implements IPSDEServiceAPIMethod {
  get codeName(): string {
    return this.M.codeName;
  }

  get codeName2(): string {
    return this.M.codeName2;
  }

  get dataAccessAction(): string {
    return this.M.dataAccessAction;
  }

  get dynaModelFilePath(): string {
    return this.M.dynaModelFilePath;
  }

  get extendMode(): 0 | 2 {
    return this.M.extendMode != null ? this.M.extendMode : 0;
  }

  get memo(): string {
    return this.M.memo;
  }

  get methodParam(): string {
    return this.M.methodParam;
  }

  get methodParam2(): string {
    return this.M.methodParam2;
  }

  get methodType(): 'DEACTION' | 'FETCH' | 'SELECT' | 'FETCHTEMP' | 'SELECTTEMP' | 'USER' | 'USER2' | 'USER3' | 'USER4' {
    return this.M.methodType;
  }

  get name(): string {
    return this.M.name;
  }

  protected psdeaction: IPSDEAction | null = null;

  getPSDEAction(): IPSDEAction | null {
    if (this.psdeaction != null) return this.psdeaction;
    const value = this.M.getPSDEAction;
    if (value == null) {
      return null;
    }
    const ipsdeserviceapi = this.getParentPSModelObject('dataentity.service.IPSDEServiceAPI') as IPSDEServiceAPI;
    if (ipsdeserviceapi != null) {
      this.psdeaction = ipsdeserviceapi.getPSDataEntityMust().findPSDEAction(value);
    }
    return this.psdeaction;
  }

  get psDEAction(): IPSDEAction | null {
    return this.getPSDEAction();
  }

  getPSDEActionMust(): IPSDEAction {
    const value = this.getPSDEAction();
    if (value == null) {
      throw new Error('未指定实体行为');
    }
    return value;
  }

  protected psdedataset: IPSDEDataSet | null = null;

  getPSDEDataSet(): IPSDEDataSet | null {
    if (this.psdedataset != null) return this.psdedataset;
    const value = this.M.getPSDEDataSet;
    if (value == null) {
      return null;
    }
    const ipsdeserviceapi = this.getParentPSModelObject('dataentity.service.IPSDEServiceAPI') as IPSDEServiceAPI;
    if (ipsdeserviceapi != null) {
      this.psdedataset = ipsdeserviceapi.getPSDataEntityMust().findPSDEDataSet(value);
    }
    return this.psdedataset;
  }

  get psDEDataSet(): IPSDEDataSet | null {
    return this.getPSDEDataSet();
  }

  getPSDEDataSetMust(): IPSDEDataSet {
    const value = this.getPSDEDataSet();
    if (value == null) {
      throw new Error('未指定数据集合');
    }
    return value;
  }

  protected psdeserviceapimethodinput: IPSDEServiceAPIMethodInput | null = null;

  getPSDEServiceAPIMethodInput(): IPSDEServiceAPIMethodInput | null {
    if (this.psdeserviceapimethodinput != null) return this.psdeserviceapimethodinput;
    const value = this.M.getPSDEServiceAPIMethodInput;
    if (value == null) {
      return null;
    }
    this.psdeserviceapimethodinput = this.getPSModel4('dataentity.service.IPSDEServiceAPIMethodInput', value, 'getPSDEServiceAPIMethodInput') as IPSDEServiceAPIMethodInput;
    return this.psdeserviceapimethodinput;
  }

  get psDEServiceAPIMethodInput(): IPSDEServiceAPIMethodInput | null {
    return this.getPSDEServiceAPIMethodInput();
  }

  getPSDEServiceAPIMethodInputMust(): IPSDEServiceAPIMethodInput {
    const value = this.getPSDEServiceAPIMethodInput();
    if (value == null) {
      throw new Error('未指定方法输入对象');
    }
    return value;
  }

  protected psdeserviceapimethodreturn: IPSDEServiceAPIMethodReturn | null = null;

  getPSDEServiceAPIMethodReturn(): IPSDEServiceAPIMethodReturn | null {
    if (this.psdeserviceapimethodreturn != null) return this.psdeserviceapimethodreturn;
    const value = this.M.getPSDEServiceAPIMethodReturn;
    if (value == null) {
      return null;
    }
    this.psdeserviceapimethodreturn = this.getPSModel4('dataentity.service.IPSDEServiceAPIMethodReturn', value, 'getPSDEServiceAPIMethodReturn') as IPSDEServiceAPIMethodReturn;
    return this.psdeserviceapimethodreturn;
  }

  get psDEServiceAPIMethodReturn(): IPSDEServiceAPIMethodReturn | null {
    return this.getPSDEServiceAPIMethodReturn();
  }

  getPSDEServiceAPIMethodReturnMust(): IPSDEServiceAPIMethodReturn {
    const value = this.getPSDEServiceAPIMethodReturn();
    if (value == null) {
      throw new Error('未指定方法返回对象');
    }
    return value;
  }

  protected pssubsysserviceapidemethod: IPSSubSysServiceAPIDEMethod | null = null;

  getPSSubSysServiceAPIDEMethod(): IPSSubSysServiceAPIDEMethod | null {
    if (this.pssubsysserviceapidemethod != null) return this.pssubsysserviceapidemethod;
    const value = this.M.getPSSubSysServiceAPIDEMethod;
    if (value == null) {
      return null;
    }
    const ipsdeserviceapi = this.getParentPSModelObject('dataentity.service.IPSDEServiceAPI') as IPSDEServiceAPI;
    if (ipsdeserviceapi != null) {
      this.pssubsysserviceapidemethod = ipsdeserviceapi.getPSDataEntityMust().getPSSubSysServiceAPIDEMust().findPSSubSysServiceAPIDEMethod(value);
    }
    return this.pssubsysserviceapidemethod;
  }

  get psSubSysServiceAPIDEMethod(): IPSSubSysServiceAPIDEMethod | null {
    return this.getPSSubSysServiceAPIDEMethod();
  }

  getPSSubSysServiceAPIDEMethodMust(): IPSSubSysServiceAPIDEMethod {
    const value = this.getPSSubSysServiceAPIDEMethod();
    if (value == null) {
      throw new Error('未指定重定向外部服务接口实体方法');
    }
    return value;
  }

  protected pssyssfplugin: IPSSysSFPlugin | null = null;

  getPSSysSFPlugin(): IPSSysSFPlugin | null {
    if (this.pssyssfplugin != null) return this.pssyssfplugin;
    const value = this.M.getPSSysSFPlugin;
    if (value == null) {
      return null;
    }
    this.pssyssfplugin = this.getPSModel4('res.IPSSysSFPlugin', value, 'getPSSysSFPlugin') as IPSSysSFPlugin;
    return this.pssyssfplugin;
  }

  get psSysSFPlugin(): IPSSysSFPlugin | null {
    return this.getPSSysSFPlugin();
  }

  getPSSysSFPluginMust(): IPSSysSFPlugin {
    const value = this.getPSSysSFPlugin();
    if (value == null) {
      throw new Error('未指定后端扩展插件');
    }
    return value;
  }

  get parentKeyMode(): 'DEFAULT' | 'CHILDOF' | 'IGNORE' | 'USER' | 'USER2' | 'USER3' | 'USER4' {
    return this.M.parentKeyMode || 'DEFAULT';
  }

  get requestField(): string {
    return this.M.requestField;
  }

  get requestMethod(): 'GET' | 'HEAD' | 'POST' | 'PUT' | 'PATCH' | 'DELETE' | 'OPTIONS' | 'TRACE' {
    return this.M.requestMethod;
  }

  get requestParamType(): 'NONE' | 'FIELD' | 'FIELDS' | 'ENTITY' | 'ENTITIES' | 'OBJECT' | 'OBJECTS' {
    return this.M.requestParamType;
  }

  get requestPath(): string {
    return this.M.requestPath;
  }

  get returnValueType(): 'VOID' | 'SIMPLE' | 'SIMPLES' | 'ENTITY' | 'ENTITIES' | 'OBJECT' | 'OBJECTS' | 'LINKENTITY' | 'LINKENTITIES' | 'ASYNCACTION' | 'SSE' | 'USER' | 'USER2' {
    return this.M.returnValueType;
  }

  get tempDataMode(): 0 | 1 | 2 {
    return this.M.tempDataMode;
  }

  get uniqueTag(): string {
    return this.M.uniqueTag;
  }

  get userCat(): string {
    return this.M.userCat;
  }

  get userTag(): string {
    return this.M.userTag;
  }

  get userTag2(): string {
    return this.M.userTag2;
  }

  get userTag3(): string {
    return this.M.userTag3;
  }

  get userTag4(): string {
    return this.M.userTag4;
  }

  get enableTestMethod(): boolean {
    return this.M.enableTestMethod;
  }

  get needResourceKey(): boolean {
    return this.M.needResourceKey != null ? this.M.needResourceKey : false;
  }

  get noServiceCodeName(): boolean {
    return this.M.noServiceCodeName != null ? this.M.noServiceCodeName : false;
  }

  get cls(): string {
    return 'PSDEServiceAPIMethodImpl';
  }

  instanceof(cls: string): boolean {
    if (cls == 'dataentity.service.IPSDEServiceAPIMethod') return true;
    return super.instanceof(cls);
  }
}
